package com.jie.myvhr.service;

import com.jie.myvhr.bean.Department;
import com.jie.myvhr.mapper.DepartmentMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author jie
 * @date 2019/6/30 -15:56
 */
@Service
@Transactional
public class DepartmentService {

    @Resource
    private DepartmentMapper departmentMapper;

    /**
     * 根据父级部门id查询部门
     * @param pid 父级id
     */
    public List<Department> getDepByPid(Long pid) {
        return departmentMapper.getDepByPid(pid);
    }
    /**
     * 查询all部门
     */
    public List<Department> getAllDeps() {
        return departmentMapper.getAllDeps();
    }

    public int addDep(Department department) {
        department.setEnabled(true);
        departmentMapper.addDep(department);
        return department.getResult();
    }
    public int deleteDep(Long did) {
        Department department = new Department();
        department.setId(did);
        departmentMapper.deleteDep(department);
        return department.getResult();
    }

}
